package com.swe.chums.dao.example;

import java.math.*;
import java.util.Date;
import java.util.List;
import com.swe.chums.dao.RatingDao;
import com.swe.chums.dao.model.Rating;
import com.swe.chums.dao.exceptions.RatingDaoException;
import com.swe.chums.dao.factory.DaoFactory;

public class RatingDaoExample
{
	/**
	 * Method 'main'
	 * 
	 * @param arg
	 * @throws Exception
	 */
	public static void main(String[] arg) throws Exception
	{
		// Uncomment one of the lines below to test the generated code
		
		// findAll();
		// findByRatingType(0);
		// findByUser(0);
		// findByWebResource(0);
		// findWhereIdEquals(0);
		// findWhereWebResourceIdEquals(0);
		// findWhereRatingTypeIdEquals(0);
		// findWhereUserIdEquals(0);
	}

	/**
	 * Method 'findAll'
	 * 
	 * @throws Exception
	 */
	public static void findAll() throws Exception
	{
		RatingDao dao = DaoFactory.createRatingDao();
		List<Rating> _result = dao.findAll();
		for (Rating dto : _result) {
			display(dto);
		}
		
	}

	/**
	 * Method 'findByRatingType'
	 * 
	 * @param ratingTypeId
	 * @throws Exception
	 */
	public static void findByRatingType(int ratingTypeId) throws Exception
	{
		RatingDao dao = DaoFactory.createRatingDao();
		List<Rating> _result = dao.findByRatingType(ratingTypeId);
		for (Rating dto : _result) {
			display(dto);
		}
		
	}

	/**
	 * Method 'findByUser'
	 * 
	 * @param userId
	 * @throws Exception
	 */
	public static void findByUser(int userId) throws Exception
	{
		RatingDao dao = DaoFactory.createRatingDao();
		List<Rating> _result = dao.findByUser(userId);
		for (Rating dto : _result) {
			display(dto);
		}
		
	}

	/**
	 * Method 'findByWebResource'
	 * 
	 * @param webResourceId
	 * @throws Exception
	 */
	public static void findByWebResource(int webResourceId) throws Exception
	{
		RatingDao dao = DaoFactory.createRatingDao();
		List<Rating> _result = dao.findByWebResource(webResourceId);
		for (Rating dto : _result) {
			display(dto);
		}
		
	}

	/**
	 * Method 'findWhereIdEquals'
	 * 
	 * @param id
	 * @throws Exception
	 */
	public static void findWhereIdEquals(int id) throws Exception
	{
		RatingDao dao = DaoFactory.createRatingDao();
		List<Rating> _result = dao.findWhereIdEquals(id);
		for (Rating dto : _result) {
			display(dto);
		}
		
	}

	/**
	 * Method 'findWhereWebResourceIdEquals'
	 * 
	 * @param webResourceId
	 * @throws Exception
	 */
	public static void findWhereWebResourceIdEquals(int webResourceId) throws Exception
	{
		RatingDao dao = DaoFactory.createRatingDao();
		List<Rating> _result = dao.findWhereWebResourceIdEquals(webResourceId);
		for (Rating dto : _result) {
			display(dto);
		}
		
	}

	/**
	 * Method 'findWhereRatingTypeIdEquals'
	 * 
	 * @param ratingTypeId
	 * @throws Exception
	 */
	public static void findWhereRatingTypeIdEquals(int ratingTypeId) throws Exception
	{
		RatingDao dao = DaoFactory.createRatingDao();
		List<Rating> _result = dao.findWhereRatingTypeIdEquals(ratingTypeId);
		for (Rating dto : _result) {
			display(dto);
		}
		
	}

	/**
	 * Method 'findWhereUserIdEquals'
	 * 
	 * @param userId
	 * @throws Exception
	 */
	public static void findWhereUserIdEquals(int userId) throws Exception
	{
		RatingDao dao = DaoFactory.createRatingDao();
		List<Rating> _result = dao.findWhereUserIdEquals(userId);
		for (Rating dto : _result) {
			display(dto);
		}
		
	}

	/**
	 * Method 'display'
	 * 
	 * @param dto
	 */
	public static void display(Rating dto)
	{
		StringBuffer buf = new StringBuffer();
		buf.append( dto.getId() );
		buf.append( ", " );
		buf.append( dto.getWebResourceId() );
		buf.append( ", " );
		buf.append( dto.getRatingTypeId() );
		buf.append( ", " );
		buf.append( dto.getUserId() );
		System.out.println( buf.toString() );
	}

}
